Note: Write R code in external R scripts, and use read_chunk() to read them into the current document.
The tidyverse package set.
Obtain the surgical wait times data from the Nova Scotia Government Open Data Portal.
The data set has been manually updated by Carlo Carandang per the comments in the data analytics report. A detailed algorithm addressing the various strategies to impute the missing values for some features remains to be documented for reproducibility as newer data becomes available.
## Warning: package 'stringr' was built under R version 3.4.3
## Warning: package 'tibble' was built under R version 3.4.3
[1] Period Specialty Procedure Provider
[5] Zone Facility Year Quarter
[9] Consult_Median Consult_90th Surgery_Median Surgery_90th
specialty
all specialties
cardiac
dental
general
neurosurgery
obstetrics/gynaecology
ophthalmology
oral and maxillofacial
oral maxillofacial
orthopaedic
otolaryngology (ent)
plastic
thoracic
urology
vascular
feature missing_count nonmissing_count
procedure 0 6843
specialty 0 6843
procedure observations
all 296
hernia repair (adult) 185
hernia repair - inguinal/femoral 177
gallbladder surgery 166
hysterectomy (cancer not suspected) 159
feature missing_count nonmissing_count
consult_90th 12 284
consult_median 12 284
facility 0 296
period 0 296
procedure 0 296
provider 0 296
quarter 296 0
specialty 0 296
surgery_90th 0 296
surgery_median 0 296
year 296 0
zone 0 296
specialty minimum maximum average sigma total observations
cardiac 66 198 157 49 702 5
dental 148 1032 327 319 7006 16
general 65 2234 177 298 14432 56
neurosurgery 155 949 252 236 3081 10
obstetrics/gynaecology 64 882 199 149 9573 41
ophthalmology 115 2875 392 497 16779 33
oral maxillofacial 171 620 421 159 4332 11
orthopaedic 162 1365 662 318 26539 38
otolaryngology (ent) 136 1081 390 258 11910 25
plastic 151 738 372 186 5598 15
thoracic 73 449 179 134 1307 6
urology 61 819 219 170 6002 22
vascular 112 685 307 242 2151 6
## Warning: Removed 12 rows containing missing values (geom_point).
## List of 1
## $ axis.text.x:List of 11
## ..$ family : NULL
## ..$ face : NULL
## ..$ colour : NULL
## ..$ size : NULL
## ..$ hjust : num 1
## ..$ vjust : NULL
## ..$ angle : num 45
## ..$ lineheight : NULL
## ..$ margin : NULL
## ..$ debug : NULL
## ..$ inherit.blank: logi FALSE
## ..- attr(*, "class")= chr [1:2] "element_text" "element"
## - attr(*, "class")= chr [1:2] "theme" "gg"
## - attr(*, "complete")= logi FALSE
## - attr(*, "validate")= logi TRUE
## Warning: Ignoring 12 observations
## Warning in RColorBrewer::brewer.pal(N, "Set2"): n too large, allowed maximum for palette Set2 is 8
## Returning the palette you asked for with that many colors
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: 'box' objects don't have these attributes: 'text'
## Valid attributes include:
## 'type', 'visible', 'showlegend', 'legendgroup', 'opacity', 'name', 'uid', 'ids', 'customdata', 'hoverinfo', 'hoverlabel', 'stream', 'y', 'x', 'x0', 'y0', 'whiskerwidth', 'boxpoints', 'boxmean', 'jitter', 'pointpos', 'orientation', 'marker', 'line', 'fillcolor', 'xaxis', 'yaxis', 'idssrc', 'customdatasrc', 'hoverinfosrc', 'ysrc', 'xsrc', 'key', 'set', 'frame', 'transforms', '_isNestedKey', '_isSimpleKey', '_isGraticule'
## Warning: Ignoring 12 observations
## Warning: Ignoring 12 observations
## Warning: Ignoring 12 observations
skewness(wait_time_distribution_by_specialty$consult_90th, na.rm = TRUE)
## [1] 5.756205
kurtosis(wait_time_distribution_by_specialty$consult_90th, na.rm = TRUE)
## [1] 47.00944
skewness(wait_time_distribution_by_specialty$surgery_90th)
## [1] 2.301818
kurtosis(wait_time_distribution_by_specialty$surgery_90th)
## [1] 8.162021
## Warning: package 'broom' was built under R version 3.4.3
##
## Attaching package: 'purrr'
## The following object is masked from 'package:magrittr':
##
## set_names
Call:
lm(formula = specialty90 ~ specialty)
Coefficients:
(Intercept) specialtycardiac
257.71 -117.31
specialtydental specialtyneurosurgery
180.16 50.39
specialtyobstetrics/gynaecology specialtyophthalmology
-24.23 250.74
specialtyoral maxillofacial specialtyorthopaedic
136.10 440.68
specialtyotolaryngology (ent) specialtyplastic
218.69 115.49
specialtythoracic specialtyurology
-39.88 15.10
specialtyvascular
100.79
Call:
lm(formula = specialty90 ~ specialty)
Residuals:
Min 1Q Median 3Q Max
-536.39 -144.57 -66.16 70.76 2366.55
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 257.71 38.80 6.643 1.68e-10 ***
specialtycardiac -117.31 135.51 -0.866 0.387417
specialtydental 180.16 82.30 2.189 0.029447 *
specialtyneurosurgery 50.39 99.67 0.506 0.613607
specialtyobstetrics/gynaecology -24.23 59.68 -0.406 0.685083
specialtyophthalmology 250.74 63.71 3.935 0.000106 ***
specialtyoral maxillofacial 136.10 95.75 1.421 0.156338
specialtyorthopaedic 440.68 61.02 7.222 5.19e-12 ***
specialtyotolaryngology (ent) 218.69 69.83 3.131 0.001930 **
specialtyplastic 115.49 84.41 1.368 0.172388
specialtythoracic -39.88 124.72 -0.320 0.749385
specialtyurology 15.10 73.05 0.207 0.836358
specialtyvascular 100.79 124.72 0.808 0.419727
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Residual standard error: 290.3 on 271 degrees of freedom
Multiple R-squared: 0.2383, Adjusted R-squared: 0.2046
F-statistic: 7.066 on 12 and 271 DF, p-value: 3.522e-11
r.squared adj.r.squared sigma statistic p.value df logLik
1 0.2383158 0.2045881 290.3315 7.065874 3.522272e-11 13 -2006.896
AIC BIC deviance df.residual
1 4041.791 4092.877 22843240 271
[1] "NULL Hypothesis:"
[1] "reject"
(Intercept) specialtycardiac
257.71429 -117.31429
specialtydental specialtyneurosurgery
180.16071 50.38571
specialtyobstetrics/gynaecology specialtyophthalmology
-24.22648 250.74026
specialtyoral maxillofacial specialtyorthopaedic
136.10390 440.68045
specialtyotolaryngology (ent) specialtyplastic
218.68571 115.48571
specialtythoracic specialtyurology
-39.88095 15.10390
specialtyvascular
100.78571
name value
(Intercept) 257.71429
specialtycardiac -117.31429
specialtydental 180.16071
specialtyneurosurgery 50.38571
specialtyobstetrics/gynaecology -24.22648
specialtyophthalmology 250.74026
specialtyoral maxillofacial 136.10390
specialtyorthopaedic 440.68045
specialtyotolaryngology (ent) 218.68571
specialtyplastic 115.48571
specialtythoracic -39.88095
specialtyurology 15.10390
specialtyvascular 100.78571
name value
intercept 257.71429
cardiac -117.31429
dental 180.16071
neurosurgery 50.38571
obstetrics/gynaecology -24.22648
ophthalmology 250.74026
oral maxillofacial 136.10390
orthopaedic 440.68045
otolaryngology (ent) 218.68571
plastic 115.48571
thoracic -39.88095
urology 15.10390
vascular 100.78571
## Analysis of Variance Table
##
## Response: specialty90
## Df Sum Sq Mean Sq F value Pr(>F)
## specialty 12 7147193 595599 7.0659 3.522e-11 ***
## Residuals 271 22843240 84292
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## [1] "Df" "Sum Sq" "Mean Sq" "F value" "Pr(>F)"
## [1] "df" "sumsq" "meansq" "fvalue" "pr(>f)"
## Analysis of Variance Table
##
## Response: specialty90
## df sumsq meansq fvalue pr(>f)
## specialty 12 7147193 595599 7.0659 3.5223e-11
## Residuals 271 22843240 84292
## [1] "ANOVA of the linear regression model; NULL Hypothesis:"
## [1] "reject"